var isLogin = false;
var title = ["奶乳制品", "清洁用品", "纸品湿巾", "水饮冲调", "京东生鲜"];
var index = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
var leftBox = [
    ["早餐奶", "纯牛奶", "风味奶", "酸奶", "成人奶粉", "乳酸菌", "欧德堡", "蒙牛"],
    ["手洗洗衣液", "洗衣粉", "洗衣皂", "洗手液", "衣物护理液"],
    ["抽纸", "卷纸", "湿巾", "手帕纸", "厨房用纸", "商务用纸"],
    ["饮用水", "饮料", "冲调", "咖啡/奶茶", "蜂蜜/柚子茶", "营养麦片", "茶叶礼盒", "进口饮料"],
    ["小龙虾", "包子", "香梨", "海参", "三文鱼", "烧烤食材", "蔬菜", "东家菜"]
]
var goodInfo = [
    ["韩国进口宾格瑞(BINGGRAE)香蕉味牛奶饮",
        "伊利QQ星儿童成长牛奶(健固型)125ml*20盒-(新老包装随机)",
        "力大狮Lactasoy 原味豆奶125ml*6盒泰国进口营养早餐",
        "韩国进口宾格瑞(BINGGRAE)草莓味牛奶饮",
        "燕塘原味酸奶饮品200ml*16盒/箱",
        "金日禾野中老年核桃粉礼盒无加蔗糖礼盒装谷物早餐冲饮",
        "德国DMK进口牛奶欧德堡(Oldenburger）超高温处理",
        "燕塘原味酸奶饮品250ml*16盒/箱",
        "伊利中老年奶粉双听加量礼盒送父母礼物(限量款)",
        "桂格(QUAKER)燕麦片健康礼盒即食燕麦片加量囤货装"
    ],
    ["绿伞蓝泡泡马桶清洁剂50g*5粒洁厕宝",
        "威洁士快速衣领净衣领洗衣液优惠装500ml×2",
        "绿伞洗衣机槽清洗剂375g*2盒滚筒波轮洗衣机清洁除垢剂",
        "金纺柔顺剂衣物护理剂柔软护型防静电淡雅樱花香味4L",
        "洁成金属钢丝球不锈钢清洁球6只装",
        "尚岛宜家木棉签棉棒200头装美容化妆耳鼻清洁100只",
        "雕牌加香透明皂/洗衣皂206g*2块肥皂(新老包装随机)",
        "亮净洗衣机槽清洗剂125gx4清洁剂",
        "雷达杀虫气雾剂无香550ml*2灭嫜娜杀蚂蚁杀苍蛹喷雾剂",
        "滴露Dettol消毒液1.8L*2家居衣物除菌液与洗衣液、柔顺剂"
    ],
    ["舒洁(Kleenex)湿厕纸40片家庭装私处清洁湿纸巾湿巾可",
        "得宝(Tempo)湿巾盒装(5包x12片)卫生洁肤湿纸巾",
        "维达(Vinda)无芯卷纸超韧3层140g卫生纸巾*12卷",
        "舒洁(Kleenex)湿厕纸40片10包装私处清洁湿纸巾湿巾可",
        "珍爱洁面湿巾含绿茶提取液带盖抽装80片B21(新老包装随机)",
        "洁云平板纸加韧250张卫生纸6包装(新老包装交替发货)",
        "维达(Vinda)湿厕纸40片特惠装",
        "【京东超市】维达(Vinda)手帕纸超韧系列4层纸巾*12包",
        "洁柔(c&S)抽纸厨房用纸双层100抽*3包(大规格厨房纸)",
        "滴露(Dettol)卫生湿巾50片"
    ],
    ["生晒新会小青柑500g大份量木桶装茶叶礼盒装云南宫廷普洱",
        "寿全斋红糖姜茶大姨妈茶差糖月经红糖速溶姜母茶老姜汤生姜",
        "脉动(Mizone)青柠口味维生素饮料600ml *15瓶整箱装",
        "农夫山泉饮用水饮用天然水(适合婴幼儿)1L*12瓶整箱装婴儿",
        "小罐茶茶叶金罐经典茶叶拼装礼盒装非遗传承人大师作品",
        "德国原装进口酸奶德亚(Weidendorf)常温原味酸牛奶",
        "恒大冰泉长白山天然弱碱性矿泉水 500ml*24瓶整箱装",
        "加多宝凉茶植物饮料茶饮料310ml*15罐整箱装",
        "忆江南茶叶乌龙茶安溪特级铁观音竹韵茶叶礼盒装年货礼品",
        "百岁山饮用天然矿泉水570ml*24瓶整箱装"
    ],
    ["Zespri佳沛新西兰绿奇异果特大22-25个原箱装",
        "【秒杀·178元】美享时刻原肉整切牛排套餐10片进口S级牛肉",
        "国联翡翠生虾仁(BAP认证)1kg/袋156-198只海鲜",
        "红颜奶油草莓约重1kg/30-40颗年货礼盒新鲜水果",
        "佳多果新疆阿克苏苹果果径80mm-85mm约4kg新鲜水果",
        "【实付188】小牛凯西牛排套餐10片澳洲进口手工微腌牛肉",
        "首食惠新西兰羔羊肉片500g/袋首农出品羊排肉卷火锅食材",
        "杨氏YANG’S精品赣南脐橙约3kg装铂金果年货礼盒",
        "京东生鲜新疆库尔勒香梨精选特级净重2.5kg 新鲜水果",
        "京东海外直采泰国活冻白虾/女王虾(特大号)850g"
    ]
]
var goodPrice = [
    ["34.80", "49.00", "13.09", "34.80", "47.90", "79.00", "97.90", "45.00", "155.00", "55.90"],
    ["15.90", "19.90", "29.90", "47.90", "5.90", "2.50", "6.90", "19.90", "33.90", "185.00"],
    ["15.90", "24.50", "21.90", "85.90", "16.90", "24.59", "9.90", "6.49", "13.90", "21.90"],
    ["78.00", "17.90", "57.90", "108.00", "1000.00", "99.90", "45.90", "39.90", "178.00", "59.90"],
    ["159.00", "129.00", "119.00", "59.90", "89.90", "168.00", "38.90", "49.90", "69.90", "99.00"]
]
var pic = -1;
var lunbo;
function nextPng(w=1) {
    pic = (pic+w+6)%6;
    var lun = document.getElementById("lunbotu");
    lun.src="./res/l"+pic+".webp";
}
function stop(){
    clearInterval(lunbo);
}
function start(){
    lunbo = setInterval(nextPng,2500);
}
window.onload = function () {
    start();//开启轮播
    //获取用户名
    getuser();
    var box = document.getElementsByClassName("box")[0];
    for (var i = 0; i < title.length; i++) {
        //创建版面
        var goods = document.createElement("div");
        //设置版面
        goods.classList.add("goods");
        //添加到中心区
        box.appendChild(goods);
        //创建标题
        var gheader = document.createElement("div");
        gheader.classList.add("gheader");
        gheader.innerHTML = title[i];
        //添加到版面
        goods.appendChild(gheader);
        var ggood = document.createElement("div");
        ggood.classList.add("ggood");
        goods.appendChild(ggood);
        var gleft = document.createElement("div");
        gleft.classList.add("gleft");
        gleft.style.backgroundImage = "url(./res/" + index[i] + ".webp)";
        ggood.appendChild(gleft);
        var gright = document.createElement("div");
        gright.classList.add("gright");
        ggood.appendChild(gright);
        var ul = document.createElement("ul");
        gleft.appendChild(ul);
        //创建并添加左下角盒子的内容
        for (var j = 0; j < leftBox[i].length; j++) {
            var li = document.createElement("li");
            li.innerHTML = leftBox[i][j];
            ul.appendChild(li);
        }
        //创建并添加商品
        for (var j = 0; j < goodInfo[i].length; j++) {
            var gg = document.createElement("div");
            gg.classList.add("gg");
            if (j < 5) {
                gg.style.borderTop = "1px solid #676";
            }
            if (j == 4 || j == 9) {
                gg.style.borderRight = "1px solid #676";
            }
            gright.appendChild(gg);
            var img = document.createElement("img");
            img.classList.add("img");
            img.src = "./res/" + index[i] + "_" + index[j] + ".webp";
            gg.appendChild(img);
            var info = document.createElement("div");
            info.classList.add("info");
            info.innerHTML = goodInfo[i][j];
            gg.appendChild(info);
            var price = document.createElement("div");
            price.classList.add("price");
            price.innerHTML = "￥" + goodPrice[i][j];
            gg.appendChild(price);
            var ent = document.createElement("div");
            ent.classList.add("ent");
            ent.innerHTML = "加入购物车";
            gg.appendChild(ent);
        }

    }
    //添加页尾
    var footer = document.createElement("div");
    footer.classList.add("footer");
    document.getElementsByTagName("body")[0].appendChild(footer);
    var ftext = document.createElement("div");
    ftext.classList.add("ftext");
    footer.appendChild(ftext);
    var ul = document.createElement("ul");
    ftext.appendChild(ul);
    var t = ["关于我们", "联系我们", "人才招聘", "商家入驻", "广告服务", "手机京东", "友情链接", "销售联盟", "京东社区", "京东公益", "English Site"];
    for (var i = 0; i < t.length; i++) {
        var li = document.createElement("li");
        var a = document.createElement("a");
        a.href = "#";
        a.innerHTML = t[i];
        if (i == 0) {
            a.style.border = "none";
        }
        li.appendChild(a);
        ul.appendChild(li);
    }
    var span = document.createElement("span");
    span.innerHTML = "Copyright©2004-2021  京东JD.com 版权所有";
    span.style.fontSize = "12px";
    span.style.color = "#999";
    span.style.position = "absolute";
    span.style.top = "50px";
    span.style.left = "450px";
    ftext.appendChild(span);
}